package com.kai.service.impl;

import com.kai.mapper.EmpMapper;
import com.kai.mapper.ReportMapper;
import com.kai.pojo.EmpJobData;
import com.kai.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Service
public class ReportServiceImpl implements ReportService {

    @Autowired
    private ReportMapper reportMapper;

    @Override
    public EmpJobData empJobData() {

        List<Map<String, Object>> list = reportMapper.empJobData();

        //这里返回的是一个表结构 所以 用键值对的形式 map接收

        //获得到 职位 和 对应的数据 ---- 这里 s.get返回的是值 所以泛型是object类型
        List<Object> pos = list.stream().map(s -> s.get("pos")).toList();
        List<Object> num = list.stream().map(s ->  s.get("num")).toList();
        return new EmpJobData(pos, num);
    }

    @Override
    public List<Map<String, Object>> empGenderData() {

       return reportMapper.empGenderData();

    }
}
